package com.swsc.solarverse.service.schedule;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.swsc.solarverse.dao.entity.forward.ForwardDeviceInfoDO;
import com.swsc.solarverse.dao.mapper.CustomSqlMapper;
import com.swsc.solarverse.dao.mapper.SqlTableMapper;
import com.swsc.solarverse.dao.mapper.forward.*;

import java.util.List;

/**
 * @Author chencl
 * @Date 2024/6/13 16:24
 * @Version 1.0
 * @Description
 */
@lombok.extern.slf4j.Slf4j
@org.springframework.stereotype.Service
public class ForwardScadaDataTransformSchduleService {

    private final ForwardDeviceInfoMapper forwardDeviceInfoMapper;
    private final ForwardEnvironmentalMonitorDataMapper forwardEnvironmentalMonitorDataMapper;
    private final ForwardInverterDataMapper forwardInverterDataMapper;
    private final ForwardCombinerBoxDataMapper forwardCombinerBoxDataMapper;
    private final ForwardStringDataMapper forwardStringDataMapper;
    private final CustomSqlMapper customSqlMapper;
    private final SqlTableMapper sqlTableMapper;
    private List<ForwardDeviceInfoDO> forwardDeviceInfoDos;
    private List<ForwardDeviceInfoDO> envForwardDeviceInfoDos;
    private List<ForwardDeviceInfoDO> invForwardDeviceInfoDos;
    private List<ForwardDeviceInfoDO> cbxForwardDeviceInfoDos;
    private List<ForwardDeviceInfoDO> strForwardDeviceInfoDos;

    public ForwardScadaDataTransformSchduleService(ForwardDeviceInfoMapper forwardDeviceInfoMapper,
                                                   ForwardEnvironmentalMonitorDataMapper forwardEnvironmentalMonitorDataMapper,
                                                   ForwardInverterDataMapper forwardInverterDataMapper,
                                                   ForwardCombinerBoxDataMapper forwardCombinerBoxDataMapper,
                                                   ForwardStringDataMapper forwardStringDataMapper,
                                                   CustomSqlMapper customSqlMapper,
                                                   SqlTableMapper sqlTableMapper) {
        this.forwardDeviceInfoMapper = forwardDeviceInfoMapper;
        this.forwardEnvironmentalMonitorDataMapper = forwardEnvironmentalMonitorDataMapper;
        this.forwardInverterDataMapper = forwardInverterDataMapper;
        this.forwardCombinerBoxDataMapper = forwardCombinerBoxDataMapper;
        this.forwardStringDataMapper = forwardStringDataMapper;
        this.customSqlMapper = customSqlMapper;
        this.sqlTableMapper = sqlTableMapper;
    }


    public void createTableMonthSharding(String suffixs) {
        if (StringUtils.isNotBlank(suffixs)) {
            String[] suffixArr = suffixs.split(",");
            for (String suffix : suffixArr) {
                sqlTableMapper.createTableForwardCombinerBoxDataHis(suffix);
                sqlTableMapper.createTableForwardInverterDataHis(suffix);
                sqlTableMapper.createTableStringEfficiencyDay(suffix);
                sqlTableMapper.createTableForwardStringDataHis(suffix);
            }
        }
    }

}
